package com.dongdongshop.util;

import java.io.Serializable;
import java.util.List;

public class PageInfo<T> implements Serializable {
    Integer pageNumber; // 当前页
    Integer pageSize; // 每页条数
    Long total; // 总条数
    Integer totalPage; // 总页数
    Integer offset; // 起始页
    List<T> list;


    public Integer getOffset() {
        return (pageNumber -1)*pageSize;
    }

    public void setOffset(Integer offset) {
        this.offset = offset;
    }

    public Integer getPageNumber() {
        return pageNumber;
    }

    public void setPageNumber(Integer pageNumber) {
        this.pageNumber = pageNumber;
    }

    public Integer getPageSize() {
        return pageSize;
    }

    public void setPageSize(Integer pageSize) {
        this.pageSize = pageSize;
    }


    public Long getTotal() {
        return total;
    }

    public void setTotal(Long total) {
        this.total = total;
    }

    public Integer getTotalPage() {
        return (int)(total%pageSize == 0?total/pageSize:total/pageSize+1);
    }

    public void setTotalPage(Integer totalPage) {
        this.totalPage = totalPage;
    }

    public List<T> getList() {
        return list;
    }

    public void setList(List<T> list) {
        this.list = list;
    }

    @Override
    public String toString() {
        return "PageInfo{" +
                "pageNumber=" + pageNumber +
                ", pageSize=" + pageSize +
                ", total=" + total +
                ", totalPage=" + totalPage +
                ", offset=" + offset +
                ", list=" + list +
                '}';
    }
}